package cn.hzu580.action;

import java.io.InputStream;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

import cn.hzu580.entity.Message;
import cn.hzu580.service.MessageService;
import cn.hzu580.vo.MessageVO;

@Controller
@Scope("prototype")
public class MessageAction extends ActionSupport implements ModelDriven<MessageVO> {

	private InputStream inputStream;
	
	@Resource(name="message")
	private MessageService messageServices;
	
	private MessageVO messageVO;
	
	private Message json;
	
	private List<Message> jsonArray;
	

	public void write() throws Exception {
		messageServices.write(messageVO);
	}

	public void delete() throws Exception {
		messageServices.delete(messageVO);
	}

	public String getAll() throws Exception  {
		jsonArray =  messageServices.getAll(messageVO);
		return "json_array";
	}

	
	public InputStream getInputStream() {
		return inputStream;
	}


	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}
	

	public MessageService getMessageServices() {
		return messageServices;
	}


	public void setMessageServices(MessageService messageServices) {
		this.messageServices = messageServices;
	}

	
	@Override
	public MessageVO getModel() {
		messageVO = new MessageVO();
		return messageVO;
	}

	public Message getJson() {
		return json;
	}

	public void setJson(Message json) {
		this.json = json;
	}

	public List<Message> getJsonArray() {
		return jsonArray;
	}

	public void setJsonArray(List<Message> jsonArray) {
		this.jsonArray = jsonArray;
	}
	

	
	



	

	
}
